<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>地理位置</title>
</head>
<body>
  <div id="startLat"></div>
  <div id="startLon"></div>
	<script>
		(function() {
		  var options = {
			  enableHighAccuracy: true, // default false
				maximunAge: 5 * 60, // default 0
			  timeout: 10 * 1000 // default infinity
			}

		  var startPos;
		  var geoSuccess = function(position) {
		  	startPos = position;
		  	document.getElementById('startLat').innerHTML = startPos.coords.latitude;
		  	document.getElementById('startLon').innerHTML = startPos.coords.longitude;
		  };
		  var geoError = function(error) {
		  	console.log('Error occurred. : ', error);
		  	// error.code can be:
		  	//   0: unknown error
		  	//   1: permission denied
		  	//   2: position unavailable (error response from location provider)
		  	//   3: timed out

				startLat.innerHTML = 'we got error: ' + error.message
		  };
		  navigator.geolocation.getCurrentPosition(geoSuccess, geoError, options);
		})()
	</script>
</body>
</html>
